package com.cx.jvm;

/**
 * @Author:cxy
 * @Date:2021/11/27 16:38
 */
public class TestMyClassLoader {

    public static void main(String[] args) throws Exception {

        MyClassLoader loader1=new MyClassLoader("loader1");

        loader1.setPath("E:\\cxy\\workSpace\\Cx_project\\Cx_Jdk\\target\\classes\\");

        MyClassLoader loader2=new MyClassLoader(loader1, "loader2");
//
        loader2.setPath("E:\\cxy\\workSpace\\Cx_project\\Cx_Jdk\\target\\classes\\");
//
        MyClassLoader loader3=new MyClassLoader(null, "loader3");

        loader3.setPath("E:\\cxy\\workSpace\\Cx_project\\Cx_Jdk\\target\\classes\\");

        loadClassByMyClassLoader("com.cx.jvm.define.Color",loader3);

//        loadClassByMyClassLoader("com.cx.jvm.define.Red",loader3);



    }

    private static void loadClassByMyClassLoader(String name,ClassLoader loader) throws Exception{
        Class<?> c=loader.loadClass(name);
        Object obj=c.newInstance();
    }
}
